import * as echarts from 'echarts'

export default function useEchart(el) {
  const echartInstance = echarts.init(el, 'light', { renderer: 'svg' })

  const setOptions = (options) => {
    echartInstance.setOption(options)
  }

  const updateSize = () => {
    echartInstance.resize()
  }

  window.addEventListener('resize', () => {
    echartInstance.resize()
  })

  return { echartInstance, setOptions, updateSize }
}
